package net.jiupinshi.dao;

import net.jiupinshi.dto.UserDTO;
import net.jiupinshi.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @description: 请添加描述
 * @author: penghui.guo
 * @create: 2018/9/21 18:55
 */
public interface UserDao {

    //@Results
    @Select("select id, name, create_time as createTime, modify_time as modifyTime, mobile, password, status, remark" +
            " from user where id = #{id}")
    User getUserInfo(Long id);

    @Insert("insert into user (name, mobile, password, remark) values (#{name}, #{mobile}, #{password}, #{remark})")
    @Options(useGeneratedKeys = true)
    int insertUser(User user);

    @Update("update user set password = #{password}, remark = #{remark}, mobile = #{mobile}, status = #{status} where id = #{id}")
    int updateUserInfo(User user);

    @Select("select id, name, mobile, role_id as roleId" +
            " from user where mobile = #{mobile} and password = #{password}")
    UserDTO getUserInfoByPwd(@Param("mobile") String mobile, @Param("password") String password);

    @Select("select id, name from user")
    List<User> getUsers();
}
